import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;

public class MyBatisTest {
    private SqlSessionFactory sqlSessionFactory;
    private SqlSession sqlSession;

    public void inti(){
        String resource = "mybatis-config.xml";
        Reader reader = null;
        try{
            reader = Resources.getResourceAsReader(resource);
            SqlSessionFactory sqlMapper = new SqlSessionFactoryBuilder().build(reader);
            sqlSession = sqlMapper.openSession(true);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    public void findAllsStudentTest(){
        List<Student> list = sqlSession.selectList("com.mapper.StudentMapper.findAllStudent");  
                for(Student student:list){
                    System.out.println(student);
                }
    }
}
